﻿namespace Sidvall.FileSystemManager.UI.Entities
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class CleanConfig : global::Sidvall.FileSystemManager.UI.Entities.Core.BusinessBase, global::Sidvall.FileSystemManager.Data.ICleanConfig
    {
        #region Business Members

        #region CleanBackupFolders

        private bool _CleanBackupFolders = false;
        partial void OnBeforeCleanBackupFoldersPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeCleanBackupFoldersPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterCleanBackupFoldersPropertyChanged();
        public bool CleanBackupFolders
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_CleanBackupFolders);
                OnBeforeCleanBackupFoldersPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _CleanBackupFolders);
                OnBeforeCleanBackupFoldersPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("CleanBackupFolders", eventData.Value, true, true, true);
                    OnAfterCleanBackupFoldersPropertyChanged();
                }
            }
        }

        #endregion
        #region CleanBuildFolders

        private bool _CleanBuildFolders = false;
        partial void OnBeforeCleanBuildFoldersPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeCleanBuildFoldersPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterCleanBuildFoldersPropertyChanged();
        public bool CleanBuildFolders
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_CleanBuildFolders);
                OnBeforeCleanBuildFoldersPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _CleanBuildFolders);
                OnBeforeCleanBuildFoldersPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("CleanBuildFolders", eventData.Value, true, true, true);
                    OnAfterCleanBuildFoldersPropertyChanged();
                }
            }
        }

        #endregion
        #region CleanConfigId

        private System.Nullable<int> _CleanConfigId = null;
        partial void OnBeforeCleanConfigIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<int>> eventData);
        partial void OnBeforeCleanConfigIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData);
        partial void OnAfterCleanConfigIdPropertyChanged();
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public System.Nullable<int> CleanConfigId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<int>>(_CleanConfigId);
                OnBeforeCleanConfigIdPropertyGet(eventData);
                return eventData.Value;
            }
            internal set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<int>>(value, _CleanConfigId);
                OnBeforeCleanConfigIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("CleanConfigId", eventData.Value, true, true, true);
                    OnAfterCleanConfigIdPropertyChanged();
                }
            }
        }

        #endregion
        #region CleanPackageFolder

        private bool _CleanPackageFolder = false;
        partial void OnBeforeCleanPackageFolderPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeCleanPackageFolderPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterCleanPackageFolderPropertyChanged();
        public bool CleanPackageFolder
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_CleanPackageFolder);
                OnBeforeCleanPackageFolderPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _CleanPackageFolder);
                OnBeforeCleanPackageFolderPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("CleanPackageFolder", eventData.Value, true, true, true);
                    OnAfterCleanPackageFolderPropertyChanged();
                }
            }
        }

        #endregion
        #region FolderPath

        private string _FolderPath = string.Empty;
        partial void OnBeforeFolderPathPropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeFolderPathPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterFolderPathPropertyChanged();
        public string FolderPath
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_FolderPath);
                OnBeforeFolderPathPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _FolderPath);
                OnBeforeFolderPathPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("FolderPath", eventData.Value, true, true, true);
                    OnAfterFolderPathPropertyChanged();
                }
            }
        }

        #endregion
        #region RemoveSourceControlLinks

        private bool _RemoveSourceControlLinks = false;
        partial void OnBeforeRemoveSourceControlLinksPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeRemoveSourceControlLinksPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterRemoveSourceControlLinksPropertyChanged();
        public bool RemoveSourceControlLinks
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_RemoveSourceControlLinks);
                OnBeforeRemoveSourceControlLinksPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _RemoveSourceControlLinks);
                OnBeforeRemoveSourceControlLinksPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("RemoveSourceControlLinks", eventData.Value, true, true, true);
                    OnAfterRemoveSourceControlLinksPropertyChanged();
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.CleanConfigManager.GetKey(this);
            }
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool raisePropertyChanged, bool updateState)
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.CleanConfigManager.LoadInstanceField(this, fieldName, value, cascade, raisePropertyChanged, updateState);
        }

        #endregion
        #region AcceptChanges

        public void AcceptChanges()
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.CleanConfigManager.AcceptChanges(this);
        }

        #endregion
        #region Copy

        public CleanConfig Copy()
        {
            return Copy(null);
        }
        partial void OnAfterCopy(CleanConfig destination, Sidvall.Data.CopySettings settings);
        public CleanConfig Copy(Sidvall.Data.CopySettings settings)
        {
            var item = global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.CleanConfigManager.Copy(this, settings);
            OnAfterCopy(item, settings);
            return item;
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.FileSystemManager.Data.ICleanConfig item)
        {
            Import(item, null);
        }
        partial void OnAfterImport(global::Sidvall.FileSystemManager.Data.ICleanConfig source, Sidvall.Data.CopySettings settings);
        public void Import(global::Sidvall.FileSystemManager.Data.ICleanConfig item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.CleanConfigManager.Import(this, item, settings);
            OnAfterImport(item, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await ValidateAsync((Sidvall.Data.ValidationSettings)null).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            var context = new Sidvall.Business.ValidationContext(settings);
            await global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.CleanConfigManager.ValidateAsync(this, context).ConfigureAwait(false);
            await ValidateAsync(context).ConfigureAwait(false);
            return context.AllBusinessRules;
        }
        partial void OnAfterValidate(Sidvall.Data.BusinessRuleCollection itemBusinessRules, Sidvall.Business.ValidationContext context);
        public async System.Threading.Tasks.Task ValidateAsync(Sidvall.Business.ValidationContext context)
        {
            var itemBusinessRules = new Sidvall.Data.BusinessRuleCollection();
            OnAfterValidate(itemBusinessRules, context);
            await context.TaskContext.DoTaskAsync().ConfigureAwait(false);
            context.AllBusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
            var businessRulesProvider = this as Sidvall.Data.IBusinessRulesProvider;
            if (businessRulesProvider != null)
                businessRulesProvider.BusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.CleanConfigManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.FileSystemManager.UI.SystemContext.Current.EntityFacade.CleanConfigManager.Initialize(this, settings);
        }

        #endregion
        
        #region ICleanConfig Members

        bool global::Sidvall.FileSystemManager.Data.ICleanConfig.CleanBackupFolders
        {
            get
            {
                return this._CleanBackupFolders;
            }
            set
            {
                this._CleanBackupFolders = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ICleanConfig.CleanBuildFolders
        {
            get
            {
                return this._CleanBuildFolders;
            }
            set
            {
                this._CleanBuildFolders = value;
            }
        }
        System.Nullable<int> global::Sidvall.FileSystemManager.Data.ICleanConfig.CleanConfigId
        {
            get
            {
                return this._CleanConfigId;
            }
            set
            {
                this._CleanConfigId = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ICleanConfig.CleanPackageFolder
        {
            get
            {
                return this._CleanPackageFolder;
            }
            set
            {
                this._CleanPackageFolder = value;
            }
        }
        string global::Sidvall.FileSystemManager.Data.ICleanConfig.FolderPath
        {
            get
            {
                return this._FolderPath;
            }
            set
            {
                this._FolderPath = value;
            }
        }
        bool global::Sidvall.FileSystemManager.Data.ICleanConfig.RemoveSourceControlLinks
        {
            get
            {
                return this._RemoveSourceControlLinks;
            }
            set
            {
                this._RemoveSourceControlLinks = value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public CleanConfig()
        {
        }

        public CleanConfig(Sidvall.Data.DataRowState? dataRowState)
            : base(dataRowState)
        {
        }

        #endregion
    }
}